import Cookies from 'js-cookie'

export const isLogin = () => {
    return Cookies.get('isLogin')
}

export const saveUser = (user) => {
    Cookies.set('email', user.email)
    Cookies.set('phone', user.phone)
    Cookies.set('nickName', user.nickName)
    Cookies.set('isLogin', true)
    Cookies.set('id', user.id)
    Cookies.set('identity', user.identity)
    Cookies.set('summary', user.summary)
}

export const getUser = () => {
    let email = Cookies.get('email')
    let nickName = Cookies.get('nickName')
    let id = Cookies.get('id')
    let identity = Cookies.get('identity')
    let phone = Cookies.get('phone')
    let summary = Cookies.get('summary')
    return {
        id, email, nickName, identity, phone, summary
    }
}

export const removeUser = () => {
    Cookies.remove('email')
    Cookies.remove('nickName')
    Cookies.remove('id')
    Cookies.remove('identity')
    Cookies.remove('phone')
    Cookies.remove('summary')
    Cookies.remove("isLogin")
}
